package org.example.controller;


import io.swagger.annotations.Api;
import org.example.annotation.mySystemlog;
import org.example.domain.result.ResponseResult;
import org.example.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article")
@Api(tags = "文章接口")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @GetMapping("/hotArticleList")
    @mySystemlog(businessName = "热门文章列表")
    public ResponseResult hotArticleList() {
        ResponseResult result = articleService.hotArticleList();
        return result;
    }

    //分页查询文章的列表
    @GetMapping("/articleList")
//    @mySystemlog(businessName = "分页查询文章的列表")
    //ResponseResult是huanf-framework工程的domain目录的类
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){
        return articleService.articleList(pageNum,pageSize,categoryId);
    }
    @GetMapping("/{id}")
//    @mySystemlog(businessName = "获取文章内容")
    public ResponseResult getArticleDetail(@PathVariable("id") Long id){
        return articleService.getArticleDetail(id);

    }

    @PutMapping("/updateViewCount/{id}")
    @mySystemlog(businessName = "根据文章id从mysql查询文章")
    public ResponseResult updateViewCount(@PathVariable Long id){
        return articleService.updateViewCount(id);
    }

}
